package cn.com.nes.site.action.user;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.DouYinService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 抖音接入相关接口
 */
@Controller("douyin")
@RequestMapping("/douyin")
public class DouYinController {

    @Resource
    private DouYinService service;

    /**
     * 抖音授权
     *      - 获取access_token
     *      - 获取抖音用户信息
     *      - 平台绑定用户
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getAccess")
    public PageData getAccess(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.saveAccess(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getAccessTokenFromDouYin")
    public PageData getAccessTokenFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.getAccessToken(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getUserInfoFromDouYin")
    public PageData getUserInfoFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.getUserInfo(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getFansListFromDouYin")
    public PageData getFansListFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.getFansList(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getFollowsListFromDouYin")
    public PageData getFollowsListFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.getFollowsList(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/fansCheckFromDouYin")
    public PageData fansCheckFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.fansCheck(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getVideoListFromDouYin")
    public PageData getVideoListFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.videoList(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getVideoDataFromDouYin")
    public PageData getVideoDataFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.videoData(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/getVideoSerchFromDouYin")
    public PageData getVideoSerchFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.videoSearch(req);
        return res;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/getVideoSerchCommentFromDouYin")
    public PageData getVideoSerchCommentFromDouYin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response, true);
        DataReq req = req_Status.getReq();
        PageData res = service.videoSearchConmment(req);
        return res;
    }
}
